# -*- coding: utf-8 -*-

"""
Description: 工具方法
"""
import json
from bs4 import BeautifulSoup


def process_prodes(content: str) -> str:
    """获取商品详情

    Args:
        pro_item (dict): 商品 item

    Returns:
        str: _description_
    """

    # 提取商品描述和商品属性信息
    soup = BeautifulSoup(content, "html.parser")
    pro_attr = soup.find("div", class_="additional-left")
    pro_des = soup.find("div", class_="product__specification_section")

    # 创建新 html
    _description = BeautifulSoup("", "html.parser")
    div_dom = _description.new_tag("div", attrs={"class": "cxsw_description"})

    # 添加样式
    protein_style = """
    /* 产品详情部分样式 */
    .product__specification_section {
        margin: 30px 0;
        padding: 20px;
        border-radius: 8px;
        background-color: #f9f9f9;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    }
    
    .specification_head h2 {
        font-size: 24px;
        color: #333;
        margin-bottom: 15px;
        font-weight: 600;
        border-bottom: 2px solid #e0e0e0;
        padding-bottom: 10px;
    }
    
    .short__des {
        display: block;
        line-height: 1.6;
        color: #444;
        font-size: 15px;
        text-align: justify;
    }
    
    /* 参数表格样式 */
    .additional-attributes-wrapper {
        margin: 30px 0;
        padding: 20px;
        border-radius: 8px;
        background-color: #fff;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    }
    
    .additional-attributes-wrapper h2 {
        font-size: 24px;
        color: #333;
        margin-bottom: 20px;
        font-weight: 600;
        border-bottom: 2px solid #e0e0e0;
        padding-bottom: 10px;
    }
    
    .additional-attributes {
        width: 100%;
        border-collapse: collapse;
    }
    
    #product-attribute-specs-table {
        width: 100%;
        border-collapse: collapse;
    }
    
    #product-attribute-specs-table tr {
        border-bottom: 1px solid #eee;
    }
    
    #product-attribute-specs-table tr:hover {
        background-color: #f5f5f5;
    }
    
    #product-attribute-specs-table th {
        padding: 12px 15px;
        text-align: left;
        background-color: #f5f7fa;
        color: #333;
        font-weight: 600;
        width: 30%;
        vertical-align: top;
    }
    
    #product-attribute-specs-table td {
        padding: 12px 15px;
        color: #555;
        line-height: 1.5;
    }
    
    #product-attribute-specs-table a {
        color: #2c7be5;
        text-decoration: none;
        transition: color 0.2s;
    }
    
    #product-attribute-specs-table a:hover {
        color: #1a56a5;
        text-decoration: underline;
    }
    """

    style_tag = soup.new_tag("style")
    style_tag.string = protein_style
    div_dom.append(style_tag)
    div_dom.append(pro_attr)
    div_dom.append(pro_des)

    return str(div_dom)
